/**
 * 
 */
package com.yidin.lsc;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.yidin.entry.MyDynamicEntry;
import com.yidin.entry.StoreDetailEntry;
import com.yidin.logic.MainService;
import com.yidin.logic.Task;
import com.yidin.widget.Carema;

import android.R.color;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

/**
 * @author cola
 *
 */
public class UserUpdateIntroduction extends BaseActivity{
	private String AccountId;
	private Button rightBtn;
	private Button leftBtn;
	private TextView tv;
	private TextView title;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.updateintroduction);
		init();
	}
	
	@Override
	public void init() {
		// TODO Auto-generated method stub
		this.tv = (TextView) findViewById(R.id.input);
		this.title = (TextView) findViewById(R.id.title);
		this.title.setText("修改签名");
		
		this.leftBtn = (Button) findViewById(R.id.leftBtn);
		this.leftBtn.setBackgroundDrawable(null);
		this.leftBtn.setText("取消");
		this.leftBtn.setTextColor(Color.WHITE);
		this.leftBtn.setOnClickListener(cancel);
		
		this.rightBtn = (Button) findViewById(R.id.rightBtn);
		this.rightBtn.setOnClickListener(OK);
		this.rightBtn.setBackgroundDrawable(null);
		this.rightBtn.setText("确定");
		this.rightBtn.setTextColor(Color.WHITE);
		Bundle bundle = this.getIntent().getExtras();

		if (bundle != null){
			AccountId = bundle.getString("AccountId");	
		}
	}

	private OnClickListener cancel = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			finish();
		}

	};
	
	private OnClickListener OK = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			String temp = tv.getText().toString();
			if(temp == null || temp.length() == 0 || temp.length() > 140){
				Toast.makeText(UserUpdateIntroduction.this, "请检查输入的内容长度", Toast.LENGTH_LONG).show();
				return;
			}
			Map obj = new HashMap<String, String>();
			obj.put("AccountId", AccountId);
			obj.put("Introduction", temp);
			showProgress(UserUpdateIntroduction.this);//
			Task task = new Task(Task.TASK_USER_UPDATEINTRODUCTION, obj);//TASK_ACCOUNT_DETAIL
			MainService.AddNewTask(task);//TASK_NEARBY_SHOPDETAIL
		}

	};
	
	@Override
	public void refresh(Object... param) {
		// TODO Auto-generated method stub
		int task = (Integer) param[0];
		switch (task) {
		case Task.TASK_USER_UPDATEINTRODUCTION:
			StoreDetailEntry m =  (StoreDetailEntry) param[1];
			if(m.e.equals("0000"))
				Toast.makeText(this, "修改成功", Toast.LENGTH_LONG).show();
			else
				Toast.makeText(this, "修改失败", Toast.LENGTH_LONG).show();
			break;
		}
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

}
